package com.example.yuanqin.page.main

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import com.example.yuanqin.page.home.HomeFragmentEvent
import com.example.yuanqin.page.home.HomeFragmentScreen
import com.example.yuanqin.page.message.MessageFragmentScreen
import com.example.yuanqin.page.mine.MineFragmentScreen

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MaterialTheme() {
                val tabs = remember { MainSections.values() }
                val navController = rememberNavController()
                Scaffold(
                    bottomBar = {
                        mainPageBottomBar(navController = navController,
                            tabs = tabs)
                    }
                ) {
                    MainPageScreen(
                        navController = navController,
                    )
                }
            }
        }
    }
}

object MainDestinations {
    const val HOME_ROUTE = "home"
    const val SNACK_DETAIL_ROUTE = "snack"
    const val SNACK_ID_KEY = "snackId"
}


fun NavGraphBuilder.addHomeGraph(
    onSnackSelected: (Long, NavBackStackEntry) -> Unit,
) {
    composable(MainSections.FEED.route) { from ->
        HomeFragmentScreen(onEvent = {})
    }
    composable(MainSections.SEARCH.route) { from ->
        MessageFragmentScreen(onEvent = {})
    }
    composable(MainSections.CART.route) { from ->
        MineFragmentScreen(onEvent = {})
    }
}